﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Excel 2010 Functions</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
    /*code_begin*/
    var spreadNS = GcSpread.Sheets;
    $(document).ready(function () {
        var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 1 });
        initSpread(spread);
    });
    function initSpread(spread) {
        initExcel2010(spread.sheets[0]);
    };
    function initExcel2010(sheet) {
        sheet.setName("Excel 2010 Functions");

        sheet.setColumnWidth(0, 200);
        sheet.setColumnWidth(1, 400);
        sheet.setColumnWidth(2, 80);
        sheet.getColumn(0).wordWrap(true);
        sheet.getColumn(1).wordWrap(true);

        var data = [
            ["Formula", "Description", "Result"],
            ["=BETA.DIST(2,8,10,TRUE,1,3)", "Cumulative beta probability density function"],
            ["=BETA.DIST(2,8,10,FALSE,1,3)", "Beta probability density function"],
            ["=CEILING.PRECISE(4.3)", "Rounds 4.3 up to the nearest multiple of 1."],
            ["=CEILING.PRECISE(-4.3)", "Rounds -4.3 up to the nearest multiple of 1. Rounds toward 0 because the number is negative."],
            ["=CEILING.PRECISE(4.3, 2)", "Rounds 4.3 up to the nearest multiple of 2."],
            ["=CHISQ.DIST(0.5,1,TRUE)", "The chi-squared distribution for 0.5, returned as the cumulative distribution function, using 1 degree of freedom."],
            ["=CHISQ.DIST(2,3,FALSE)", "The chi-squared distribution for 2, returned as the probability density function, using 3 degrees of freedom."],
            ["=CHISQ.INV(0.93,1)", "Inverse of the left-tailed probability of the chi-squared distribution for 0.93, using 1 degree of freedom."],
            ["=CHISQ.INV(0.6,2)", "Inverse of the left-tailed probability of the chi-squared distribution for 0.6, using 2 degrees of freedom."],
            ["=CONFIDENCE.T(0.05,1,50)", "Confidence interval for the mean of a population based on a sample size of 50, with a 5% significance level and a standard deviation of 1. This is based on a Student's t-distribution."],
            ["=COVARIANCE.S({2,4,8},{5,8,11})", "Sample covariance for the data points entered as an array in the function."],
            ["=ERF.PRECISE(0.74500)", "Error function integrated between 0 and 0.74500 (0.707929)"],
            ["=ERFC.PRECISE(0.74500)", "Complementary ERF function of 0.74500."],
            ["=F.DIST(15.2069,6,4,TRUE)", "F probability using the cumulative distribution function (TRUE cumulative argument)."],
            ["=F.DIST(15.2069,6,4,FALSE)", "F probability using the probability density function (FALSE cumulative argument)."],
            ["=F.INV(0.01,6,4)", "Inverse of the F probability distribution."],
            ["=FLOOR.PRECISE(-3.2)", "Rounds -3.2 down to the nearest multiple of -1"],
            ["=FLOOR.PRECISE(3.2)", "Rounds 3.2 down to the nearest multiple of 1"],
            ["=FLOOR.PRECISE(3.2, 2)", "Rounds 3.2 down to the nearest multiple of 2"],
            ["=GAMMALN.PRECISE(4)", "Natural logarithm of the gamma function at 4"],
            ["=HYPGEOM.DIST(1,4,8,20,TRUE)", "Cumulative hypergeometric distribution function."],
            ["=HYPGEOM.DIST(1,4,8,20,FALSE)", "Probability hypergeometric distribution function."],
            ["=ISO.CEILING(4.3)", "Rounds 4.3 up to nearest multiple of 1"],
            ["=ISO.CEILING(-4.3)", "Rounds -4.3 up to nearest multiple of 1"],
            ["=ISO.CEILING(4.3, 2)", "Rounds 4.3 up to the nearest multiple of 2"],
            ["=LOGNORM.DIST(4,3.5,1.2,TRUE)", "Cumulative lognormal distribution at 4."],
            ["=LOGNORM.DIST(4,3.5,1.2,FALSE)", "Probability lognormal distribution at 4."],
            ["=NEGBINOM.DIST(10,5,0.25,TRUE)", "Cumulative negative binomial distribution."],
            ["=NEGBINOM.DIST(10,5,0.25,FALSE)", "Probability negative binomial distribution."],
            ["=NETWORKDAYS.INTL(DATE(2006,1,1),DATE(2006,1,31))", "Results in 22 future workdays. Subtracts 9 nonworking weekend days (5 Saturdays and 4 Sundays) from the 31 total days between the two dates. By default, Saturday and Sunday are considered non-working days."],
            ["=NETWORKDAYS.INTL(DATE(2006,2,28),DATE(2006,1,31))", "Results in -21, which is 21 workdays in the past."],
            ["=NETWORKDAYS.INTL(DATE(2006,1,1),DATE(2006,2,1),7,{\"2006/1/2\",\"2006/1/16\"})", "Results in 22 future workdays by sutracting 10 nonworking days (4 Fridays, 4 Saturdays, 2 Holidays) from the 32 days between Jan 1 2006 and Feb 1 2006. Uses the 7 argument for weekend, which is Friday and Saturday. There are also two holidays in this time period."],
            ["=NETWORKDAYS.INTL(DATE(2006,1,1),DATE(2006,2,1),\"0010001\",{\"2006/1/2\",\"2006/1/16\"})", "Results in 20 future workdays. Same time period as above, but with Sunday and Wednesday as weekend days."],
            ["=NORM.S.DIST(1.333333,TRUE)", "Normal cumulative distribution function at 1.333333."],
            ["=NORM.S.DIST(1.333333,FALSE)", "Normal probability distribution function at 1.333333."],
            ["=PERCENTRANK.EXC({1,2,3,4,6,6,7,8,9}, 7)", "Returns the rank of the value 7 from the array."],
            ["=PERCENTRANK.EXC({1,2,3,4,6,6,7,8,9}, 5.43)", "Returns the rank of the value 5.43 in the array."],
            ["=PERCENTRANK.EXC({1,2,3,4,6,6,7,8,9}, 5.43, 1)", "Returns the rank of the value 5.43 in the array, displaying only 1 significant digit in the result (the default is 3)."],
            ["=PERCENTILE.EXC({1,2,3,4,5,6}, 0.25)", "Interpolates when the value for the specified percentile lies between two values in the array."],
            ["=QUARTILE.EXC({1,2,3,4,5,6,7,8,9,10,11},1)", "Locates the position of the first quartile (3)."],
            ["=QUARTILE.EXC({1,2,3,4,5,6,7,8,9,10,11},3)", "Locates the position of the third quartile (9)."],
            ["=RANK.AVG(95, {89, 88, 92, 101, 94, 97, 95})", "Finds the rank (the position) of the value 95 in the array (descending order). In this case, 95 was the 3rd one in descending order."],
            ["=RANK.AVG(95, {89, 88, 92, 101, 94, 97, 95}, 1)", "Finds the rank (the position) of the value 95 in the array (ascending order). In this case, 95 was the 5th one in ascending order."],
            ["=T.DIST(60,1,TRUE)", "Student's left-tailed t-distribution for 60, returned as the cumulative distribution function, using 1 degree of freedom."],
            ["=T.DIST(8,3,FALSE)", "Student's left-tailed t-distribution for 8, returned as the probability density function, using 3 degrees of freedom."],
            ["=T.INV(0.05464,60)", "The t-value of the Student's t-distribution based on specified arguments."],
            ["=WORKDAY.INTL(DATE(2012,1,1),30,0)", "Using a 0 for the Weekend argument results in a #NUM! error."],
            ["=WORKDAY.INTL(DATE(2012,1,1),90,11)", "Finds the date 90 workdays from 1/1/2012, counting only Sundays as a weekend day (Weekend argument is 11)."],
            ["=TEXT(WORKDAY.INTL(DATE(2012,1,1),30,17), \"m/dd/yyyy\")", "Uses the TEXT function to format the resulting serial number (40944) in a \"m/dd/yyyy\" format. Finds the date 30 workdays from 1/1/2012, counting only Saturdays as a weekend day (Weekend argument is 17)."]
        ];

        sheet.setArray(0, 0, data, false);
        var r, len, i;
        for (r = 1, len = data.length; r < len; r++) {
            sheet.setFormula(r, 2, data[r][0]);
        }

        var arrayFormulaData = [
            ["=MODE.MULT({1,2,3,4,3,2,1,2,1,3})", "The formula must be entered as an array formula. It returns 1, 2, and 3 as the modes because they each appear 3 times. If the formula is not entered as an array formula, the single result is 1.", 3]
        ];

        for (i = 0, len = arrayFormulaData.length; i < len; i++) {
            var cur = arrayFormulaData[i], rows = cur[2], cols = cur[3] || 1;
            sheet.addSpan(r, 0, rows, 1);
            sheet.setValue(r, 0, cur[0]);
            sheet.addSpan(r, 1, rows, 1);
            sheet.setValue(r, 1, cur[1]);
            sheet.setArrayFormula(r, 2, rows, cols, cur[0]);
            r += rows;
        }

        for (i = 1; i < r; i++) {
            sheet.autoFitRow(i);
        }

        sheet.getColumn(2).formatter(".######");
        sheet.setFormatter(48, 2, "M/d/yyyy");

        var table = sheet.addTable("FunctionTable", 0, 0, 50, 3, spreadNS.TableStyles.medium9());
        table.rowFilter().setShowFilterButton(false);

        // Array formula with merge cells, set style like above table rows
        var rowStyle = sheet.getActualStyle(48, 0);
        sheet.getCells(50, 0, 52, 2).backColor(rowStyle.backColor);
        sheet.setBorder(new spreadNS.Range(49, 0, 4, 3), rowStyle.borderBottom, { all: true });
    }
    /*code_end*/
    </script>
</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width:100%; height:410px;border: 1px solid gray;"></div>
    </div>
</body>
</html>